<!-- 基础使用 -->
<template>
	<div>
		<quill-editor
			ref="text"
			v-model="content"
			class="editor"
			:options="editorOption"
			@blur="onEditorBlur($event)"
			@focus="onEditorFocus($event)"
			@ready="onEditorReady($event)"
			@change="onEditorChange($event)"
		/>
	</div>
</template>

<script>
	import { quillEditor } from 'vue-quill-editor'
	import 'quill/dist/quill.core.css'
	import 'quill/dist/quill.snow.css'
	import 'quill/dist/quill.bubble.css'

	export default {
		name: 'Test',
		components: {
			quillEditor
		},
		data() {
			return {
				content: '',
				editorOption: {}
			}
		},
		methods: {
			//失去焦点事件
			onEditorBlur(quill) {
				console.log('editor blur!', quill)
			},
			//获得焦点事件
			onEditorFocus(quill) {
				console.log('editor focus!', quill)
			},
			// 准备富文本编辑器
			onEditorReady(quill) {
				console.log('editor ready!', quill)
			},
			//内容改变事件
			onEditorChange({ quill, html, text }) {
				console.log('editor change!', quill, html, text)
				this.content = html
			}
		}
	}
</script>

<style lang="css" scoped>
	.editor {
		width: 1200px;
		height: 500px;
		margin: 20px auto;
	}
</style>
